<?php

function getInterests() {
	$tabInterests = array();

	if (isset($_SESSION[INTERESTS]) && !empty($_SESSION[INTERESTS]) && !isset($_GET['refresh']))
		$tabInterests = $_SESSION[INTERESTS];
	else {
		$myInterests = Interest::getAllOrderedByCategory();
		$tabInterests['interests'] = $myInterests;
        
        $myDestinations = Travel::getAll();
		$tabTravels = array();
        if($myDestinations != null && count($myDestinations) > 0){
            foreach ($myDestinations as $destination) {
                $tabTravel['place'] = $destination->name();
                $tabTravel['lat'] = $destination->lat();
                $tabTravel['lon'] = $destination->lon();
                array_push($tabTravels, $tabTravel);
            }
        }
		$tabTravels = json_encode($tabTravels);
        
        $tabInterests['travels'] = $tabTravels;
		$_SESSION[INTERESTS] = $tabInterests;
	}

	return $tabInterests;
}

?>